local sbMainConfig = require("excel.Shenbing").shenbing
local Buffer = require("buffer.Buffer")
local Utilitys = require("skill.Utilitys")
local random      = math.random
local ObjHuman = require("core.ObjHuman")

Cmds = {}
function Cmds.shangHai(obj, target, data,  rate)
    if data.isHeavyHit then return end
    if rate == 1 then
        data.isHeavyHit = 3
    end
    data.shangHai = data.shangHai*(1+rate)
end

function Cmds.bufTarget(obj, target, data, bufID,bufID2, bufID3)
    Buffer.add(bufID, target, obj)
    if bufID2 then
      Buffer.add(bufID2, target, obj)
    end
    if bufID3 then
      Buffer.add(bufID3, target, obj)
    end
    return
end

function Cmds.bufSelf(obj, target, data, bufID, bufID2, bufID3)
    Buffer.add(bufID, obj, obj)
    if bufID2 then
       Buffer.add(bufID2, obj, obj)
    end
    if bufID3 then
       Buffer.add(bufID3, obj, obj)
    end
    return
end

function Cmds.clearCD(obj)--, target, shangHai)
    Utilitys.clearSkillCooldown(obj)
    return
end


function onHit(obj, target, sbID, hitData)
  local conf = sbMainConfig[sbID]
  if not conf then 
    return 
  end
  if random(1, 100) > conf.juejiRate then
    return 
  end
  local data = ObjHuman.getShenbing(obj, sbID)
  if not data or data.jueji ~= 1 then
    return 
  end
  Cmds[conf.jueji](obj, target,hitData, conf.juejiArgs[1],conf.juejiArgs[2])
end
